
package com.tz.tzgw.pc.web.dao;

import com.tz.tzgw.pc.web.model.Member;
import com.tz.tzgw.pc.web.model.RoleMenu;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;

import java.util.List;

public class RoleMenuDao {
    private final JdbcTemplate jdbcTemplate;

    public RoleMenuDao(JdbcTemplate jdbcTemplate) {
        this.jdbcTemplate = jdbcTemplate;
    }


    public Long[] getMenuIdsForRoleId(Long roleId) {
        String sql = "SELECT menu_id FROM tz_role_menu WHERE id = ?";
        List<Long> menuIds = jdbcTemplate.queryForList(sql, Long.class, roleId);
        return menuIds.toArray(new Long[0]);
    }


    public List<Member> getAllUsers() {
        String sql = "SELECT * FROM tz_role_menu";
        return jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(Member.class));
    }
}
